package com.ssy.lingxi.after.sale.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.ssy.lingxi.after.sale.handler.converter.JpaJsonToPayProveBOConverter;
import com.ssy.lingxi.after.sale.model.bo.PayProveBO;

import javax.persistence.*;
import java.io.Serializable;

/**
 * 退货退款明细
 * @author 伍将
 * @date 2020/9/23
 * @version 2.0.0
 */
@Entity
@Table(schema = "public", name = "as_return_goods_refund_detail",
        indexes = {@Index(name = "as_return_goods_refund_detail_return_id_idx", columnList = "returnId"),
                @Index(name = "as_return_goods_refund_detail_order_id_idx", columnList = "orderId"),
                @Index(name = "as_return_goods_refund_detail_pay_id_idx", columnList = "payId")})
public class ReturnGoodsRefundDetailDO implements Serializable {

    private static final long serialVersionUID = 8751120568909857513L;

    /**
     * id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "return_goods_refund_detail_seq")
    @SequenceGenerator(sequenceName = "as_return_goods_refund_detail_seq", name = "return_goods_refund_detail_seq", allocationSize = 1)
    private Long id;

    /**
     * 退货id
     */
    @Column(columnDefinition = "int8")
    private Long returnId;

    /**
     * 订单号
     */
    @Column(columnDefinition = "varchar(40)")
    private String orderNo;

    /**
     * 订单id
     */
    @Column(columnDefinition = "int8")
    private Long orderId;

    /**
     * 支付id
     */
    @Column(columnDefinition = "int8")
    private Long payId;

    /**
     * 支付外部状态：1.待支付2.待确认支付结果3.确认到账4.确认未到账
     */
    @Column(columnDefinition = "int")
    private Integer externalState;

    /**
     * 支付次数
     */
    @Column(columnDefinition = "int")
    private Integer payCount;

    /**
     * 支付环节
     */
    @Column(columnDefinition = "varchar(50)")
    private String payNode;

    /**
     * 支付比例
     */
    @Column(columnDefinition = "decimal")
    private Double payRatio;

    /**
     * 支付金额
     */
    @Column(columnDefinition = "decimal")
    private Double payAmount;

    /**
     * 支付方式：1.线上支付 2.线下支付 3.授信额度支付 4.货到付款支付
     */
    @Column(columnDefinition = "int")
    private Integer payWay;

    /**
     * 支付渠道：0.积分支付 1.支付宝 2.微信 3.银联 4.余额支付 5.线下支付线上确认 6.授信额度支付 7.货到付款
     */
    @Column(columnDefinition = "int8")
    private Long channel;

    /**
     * 支付时间
     */
    @Column(columnDefinition = "int8")
    private Long payTime;
    /**
     * 确认退款到账时间
     */
    @Column(columnDefinition = "int8")
    private Long confirmTime;

    /**
     * 退款金额
     */
    @Column(columnDefinition = "decimal")
    private Double refundAmount;

    /**
     * 待退款金额
     */
    @Column(columnDefinition = "decimal")
    private Double tobeRefundAmount;

    /**
     * 外部状态:1.待退款,2.待确认退款,3.退款未到账,4.退款到账
     */
    @Column(columnDefinition = "int")
    private Integer outerStatus;

    /**
     * 内部状态:1.未退款,2.退款失败,3.退款成功,4.无需退款
     */
    @Column(columnDefinition = "int")
    private Integer innerStatus;

    /**
     * 退款时间
     */
    @Column(columnDefinition = "int8")
    private Long refundTime = 0L;

    /**
     * 创建时间
     */
    @Column(columnDefinition = "int8")
    private Long createTime;

    /**
     * 更新时间
     */
    @Column(columnDefinition = "int8")
    private Long updateTime = 0L;

    /**
     * 所属退货商品
     */
    @JsonBackReference
    @ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
    @JoinColumn(name = "detail_id", referencedColumnName = "id")
    private ReturnGoodsDetailDO returnGoods;

    /**
     * 支付凭证
     */
    @Convert(converter = JpaJsonToPayProveBOConverter.class)
    @Column(columnDefinition = "jsonb")
    private PayProveBO payProve;

    /**
     * 交易支付id
     */
    @Column(columnDefinition = "varchar(50)")
    private String transactionPayId = "";

    /**
     * 支付配置：1.平台代收 2.会员直接到账
     */
    @Column(columnDefinition = "int8")
    private Long payRuleId = 2L;

    /**
     * 退款备注
     */
    @Column(columnDefinition = "varchar(500)")
    private String refundRemark = "";

    /**
     * 生成退款号
     */
    @Column(columnDefinition = "varchar(50)")
    private String tradeNo;

    public Double getTobeRefundAmount() {
        return tobeRefundAmount;
    }

    public void setTobeRefundAmount(Double tobeRefundAmount) {
        this.tobeRefundAmount = tobeRefundAmount;
    }

    public Long getPayRuleId() {
        return payRuleId;
    }

    public void setPayRuleId(Long payRuleId) {
        this.payRuleId = payRuleId;
    }

    public String getTransactionPayId() {
        return transactionPayId;
    }

    public void setTransactionPayId(String transactionPayId) {
        this.transactionPayId = transactionPayId;
    }

    public String getRefundRemark() {
        return refundRemark;
    }

    public void setRefundRemark(String refundRemark) {
        this.refundRemark = refundRemark;
    }

    public PayProveBO getPayProve() {
        return payProve;
    }

    public void setPayProve(PayProveBO payProve) {
        this.payProve = payProve;
    }

    public Long getReturnId() {
        return returnId;
    }

    public void setReturnId(Long returnId) {
        this.returnId = returnId;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Integer getPayCount() {
        return payCount;
    }

    public void setPayCount(Integer payCount) {
        this.payCount = payCount;
    }

    public String getPayNode() {
        return payNode;
    }

    public void setPayNode(String payNode) {
        this.payNode = payNode;
    }

    public Double getPayRatio() {
        return payRatio;
    }

    public void setPayRatio(Double payRatio) {
        this.payRatio = payRatio;
    }

    public Double getPayAmount() {
        return payAmount;
    }

    public void setPayAmount(Double payAmount) {
        this.payAmount = payAmount;
    }

    public Integer getPayWay() {
        return payWay;
    }

    public void setPayWay(Integer payWay) {
        this.payWay = payWay;
    }

    public Long getChannel() {
        return channel;
    }

    public void setChannel(Long channel) {
        this.channel = channel;
    }

    public Long getPayTime() {
        return payTime;
    }

    public void setPayTime(Long payTime) {
        this.payTime = payTime;
    }

    public Long getConfirmTime() {
        return confirmTime;
    }

    public void setConfirmTime(Long confirmTime) {
        this.confirmTime = confirmTime;
    }

    public Double getRefundAmount() {
        return refundAmount;
    }

    public void setRefundAmount(Double refundAmount) {
        this.refundAmount = refundAmount;
    }

    public Integer getOuterStatus() {
        return outerStatus;
    }

    public void setOuterStatus(Integer outerStatus) {
        this.outerStatus = outerStatus;
    }

    public Integer getInnerStatus() {
        return innerStatus;
    }

    public void setInnerStatus(Integer innerStatus) {
        this.innerStatus = innerStatus;
    }

    public Long getRefundTime() {
        return refundTime;
    }

    public void setRefundTime(Long refundTime) {
        this.refundTime = refundTime;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public Long getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Long updateTime) {
        this.updateTime = updateTime;
    }

    public ReturnGoodsDetailDO getReturnGoods() {
        return returnGoods;
    }

    public void setReturnGoods(ReturnGoodsDetailDO returnGoods) {
        this.returnGoods = returnGoods;
    }

    public String getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    public Long getOrderId() {
        return orderId;
    }

    public void setOrderId(Long orderId) {
        this.orderId = orderId;
    }

    public Long getPayId() {
        return payId;
    }

    public void setPayId(Long payId) {
        this.payId = payId;
    }

    public Integer getExternalState() {
        return externalState;
    }

    public void setExternalState(Integer externalState) {
        this.externalState = externalState;
    }

    public String getTradeNo() {
        return tradeNo;
    }

    public void setTradeNo(String tradeNo) {
        this.tradeNo = tradeNo;
    }
}
